﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Windows.Forms;

namespace MESCodeFile
{
    //Mga Sir, paki lagyan lahat ng comments yung codes nyo as much as possible.
    //Para kahit sino satin gumalaw madali lng maintindihan. thanks.
    
    //use for different office for document checklist
    static class documentChecklist
    {
        public static string responsibleOffice;
        public static string description;
    }

    //use for the business permit : additional, renewal, transfer ownership and location, reports 
    public struct myParam
    {
        public string action;
        public string myReferenceNumber;
        public string myApplicationNumber;
        public string myBusinessReferenceNumber;
        public string msg;
        public string status;
    }

    //use for getting the fID and fStamp of any record you want to update - for data concurrency 
    public struct updateInfo
    {
        public string fID;
        public DateTime fStamp;
    }
    //Common Data
    static class Common
    {
        public static mes_tublay.frmMain PARENT;
        public static CodeDynamiksEngine.ConfigCache CFG = new CodeDynamiksEngine.ConfigCache("settings", "Settings file for MES Tublay");
        public static string LOCPATH = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\mes_tublay\\";
        public static bool LOGGED = false;
        public static LiveNotificationSystem.PushNotification NOTIFY = null;
    }
    //Class containing application constants
    static class Const
    {
        //User manager image file buffer name.
        public const string APPLICATION_EBPLS_IMG = "application_ebpls_img";
        public const string USERMANAGERIMG = "user_manager_img";
        public const string USERCURRENT = "user_current_img";
        public const string USERBACKDOOR = "backdoor";
        public const string SAVESTATE_1 = "state0";
        public const string SAVESTATE_2 = "state1";
    }
    /// <summary>
    /// Class that represents the current user.
    /// </summary>
    public static class CurrentUser
    {
        public static string UID="";
        public static object ID = "";
        public static object STAMP = "";
        public static string PWD = "";
        public static string NAME = "";
        public static string DESIGNATION = "";
        public static System.Drawing.Bitmap IMG = mes_tublay.Properties.Resources.DefaultProfile;
        public static object[] PRIV = new object[0];
        public static bool FindPrivilege(object priv)
        {
            bool found = false;
            for (int i = 0; i < PRIV.Length; i++)
            {
                if (priv.ToString() == PRIV[i].ToString())
                {
                    found = true;
                    break;
                }
            }
            return found;
        }
        public static string USERIDNUMBER
        {
            get
            {
                long n = 0;
                if (!long.TryParse(ID.ToString(), out n)) return "";
                return n.ToString("USER0000#") + "_";
            }
        }
    }

    /// <summary>
   /// MessageBox wrapper
   /// </summary>
    public static class Confirm
    {
        public static DialogResult Question(string title, string msg)
        {
            return MessageBox.Show(msg, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }
        public static DialogResult Error(string title, string msg)
        {
            return MessageBox.Show(msg, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        public static DialogResult OkCancel(string title, string msg)
        {
            return MessageBox.Show(msg, title, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
        }
        public static DialogResult Generic(string title, string msg,  MessageBoxButtons btn, MessageBoxIcon icn)
        {
            return MessageBox.Show(msg, title, btn, icn);
        }
        public static DialogResult Info(string title, string msg)
        {
            return MessageBox.Show(msg, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
    /// <summary>
    /// Add Prefix and Suffix symbols
    /// </summary>
    public static class Sym
    {
        /// <summary>
        ///  ' - Prefix/Suffix
        /// </summary>
        /// <param name="obj">object</param>
        /// <returns>object</returns>
        public static object PQS(object obj)
        {
            return "'" + obj + "'";
        }
        /// <summary>
        /// '% - Prefix/Suffix
        /// </summary>
        /// <param name="obj">object</param>
        /// <returns>object</returns>
        public static object PQPS(object obj)
        {
            return "'%" + obj + "%'";
        }
        /// <summary>
        /// '% - Prefix
        /// </summary>
        /// <param name="obj">object</param>
        /// <returns>object</returns>
        public static object PQP(object obj)
        {
            return "'%" + obj;
        }
        /// <summary>
        /// '% - Suffix
        /// </summary>
        /// <param name="obj">object</param>
        /// <returns>object</returns>
        public static object QPS(object obj)
        {
            return  obj + "%'";
        }
    }

    public static class ControlTab
    {
        public static void Enable_Tab(TabPage page, bool enable)
        {
            ((Control)page).Enabled = enable;
        }
    }
}